package com.ganzi.ganziitem.Utils;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class CTool {
	public static void ssleep(int sec) {

		try {
			Thread.sleep(1000 * sec);
		} catch (InterruptedException e) {
		}
	}

	public static String getnowtime() {

		try {
			Calendar calendar = Calendar.getInstance();
			SimpleDateFormat dateFormat = new SimpleDateFormat(
					"yyyy-MM-dd HH:mm:ss");
			String currentTime = dateFormat.format(calendar.getTime());
			return currentTime;
		} catch (Exception e) {

		}
		return "0000-00-00 00:00:00";
	}
	
	
	public static Timestamp getnowtimestamp() {

		return new Timestamp( System.currentTimeMillis()) ;
	}

	public static String intToHexString(int a, int len) {
		try {
			len <<= 1;
			String hexString = Integer.toHexString(a);
			int b = len - hexString.length();
			if (b > 0) {
				for (int i = 0; i < b; i++) {
					hexString = "0" + hexString;
				}
			}
			return hexString.toUpperCase();

		} catch (Exception e) {
		}
		return "0000";
	}
	
	
	public static byte[] copy(byte[] data, int srcpos, int length) {
		byte[] dest = new byte[length];
		System.arraycopy(data, srcpos, dest, 0, length);
		return dest;
	}

}
